import java.util.Scanner;

public class demo28 {
    public static void main(String[] args) {
        Object locker=new Object();
        Thread t1=new Thread(()->{
            System.out.println("t1 wait之前");
            synchronized(locker){
                try {
                    locker.wait();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
            System.out.println("t1 wait之后");

        });
        Thread t2=new Thread(()->{
            System.out.println("t2wait之前");
            synchronized(locker){
                try {
                    locker.wait();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
            System.out.println("t2 wait之后");

        });
        Thread t3=new Thread(()->{
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            System.out.println("请输入内容来唤醒");
            Scanner scanner=new Scanner(System.in);
            scanner.nextInt();
            synchronized(locker){
//                locker.notify();
                locker.notifyAll();
            }
            scanner.close();
        });
        t1.start();
        t2.start();
        t3.start();
    }
}
